<template>
    <div>
        <p>名称：<input type="text" v-model="name"></p>
        <p>价格：<input type="text" v-model="price"></p>
        <p>介绍：<input type="text" v-model="status"></p>
        <p>图片：<input type="file" @change="tupian($event)"></p>
        <select  v-model="ass">
            <option v-for="(i,j) in asslist" :key="j" :value="i.id">{{i.name}}</option>
        </select>
        <p><input type="button" @click="tianjia()" value="添加"></p>
    </div>
</template>

<script>
import axios from 'axios'
import {RI_Ass_show} from '../axios_send/api.js'
export default {
    name:"Bsscre",
    data(){
        return{
            ass:"",
            name:"",
            price:"",
            status:"",
            asslist:"",

        }
    },
    created(){
        this.assshow()
    },
    methods:{
        assshow(){
            RI_Ass_show()
            .then(res=>{
                console.log(res)
                this.asslist = res
            })
        },
        tianjia(){
            var form_data = new FormData()
            form_data.append("name",this.name),
            form_data.append("price",this.price),
            form_data.append("status",this.status),
            form_data.append("img",this.file),
            form_data.append("ass",this.ass),
            
            axios({
                url:"http://127.0.0.1:8000/zks/bsscre/",
                method:"post",
                data:form_data
            }).then(res=>{
                console.log(res.data)
            })
        },
        tupian(event){
            this.file = event.target.files[0]
        },
    }
}
</script>

<style>

</style>
